/*
 * this file use AGCode auto generate.
 * Project home page: https://gitee.com/you-yuan/AutoGeneratorCode
 * Copyright(c) 2022. YouYuan https://gitee.com/you-yuan/
 */


package com.yuan.springcloud.user.service.impl;

import com.yuan.springcloud.user.bean.dto.UserSignDTO;
import com.yuan.springcloud.user.bean.po.UserSignPO;
import com.yuan.springcloud.user.bean.vo.UserSignVO;
import java.util.Date;

import com.yuan.springcloud.user.dao.UserSignDAO;
import com.yuan.springcloud.user.service.UserSignService;
import com.yuan.springcloud.user.utils.transform.UserSignTrans;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author YouYuan
 * @date 2022-04-10 21:33:17
 */
@Service
public class UserSignServiceImpl implements UserSignService {

    @Autowired
    private UserSignDAO userSignDAO;

    // region 用户签到记录
    /**通过ID查询用户签到记录*/
    @Override
    public UserSignPO getUserSignById(int id){
        return userSignDAO.selectById(id);
    }


    /**新增用户签到记录*/
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int addUserSign(UserSignVO userSignVO) {
        UserSignPO userSignPO = UserSignTrans.instance.vo2po(userSignVO);
        int id = userSignDAO.insert(userSignPO);
        return id;
    }

    /**更新用户签到记录*/
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void updateUserSign(UserSignVO userSignVO) {
        //User user = UserContext.getUser();
        UserSignPO userSignPO = UserSignTrans.instance.vo2po(userSignVO);
        userSignDAO.updateById(userSignPO);
    }

    /**删除用户签到记录*/
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void deleteUserSign(int id) {
        userSignDAO.deleteById(id);
    }
    // endregion
}